#
# @lc app=leetcode.cn id=45 lang=python
#
# [45] 跳跃游戏 II
#

# @lc code=start
class Solution(object):
    def jump(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums) == 1:
            return 0
        precover = nums[0]
        maxcover = precover
        result = 1
        i = 1
        while i <= precover:
            if precover >= len(nums)-1:
                return result
                
            maxcover = max(nums[i]+i, maxcover)
            if i == precover:
                result += 1
                precover = maxcover
            i+=1
        
        
# @lc code=end

